package cn.springcloud.alibaba.auth.common;

import com.alibaba.ttl.TransmittableThreadLocal;

public class TenantContextHolder {

	private static final ThreadLocal<String> THREAD_LOCAL_TENANT = new TransmittableThreadLocal<>();

	/**
	 * TTL 设置租户ID
	 */
	public static void setTenantId(String tenantId) {
		THREAD_LOCAL_TENANT.set(tenantId);
	}

	/**
	 * 获取TTL中的租户ID
	 */
	public static String getTenantId() {
		return THREAD_LOCAL_TENANT.get();
	}

	public static void clear() {
		THREAD_LOCAL_TENANT.remove();
	}
}
